﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MapLibrary.Players.Skills
{
    class LevelDepValue<T>
    {
        private Skill toTrack;

        private Dictionary<int, T> levelValuePairs;

        public LevelDepValue(Skill s)
        {
            toTrack = s;
            levelValuePairs = new Dictionary<int, T>();
        }

        public void AddValueForLevel(int level, T value)
        {
            levelValuePairs.Add(level, value);
        }

        public T Value
        {
            get
            {
                int level = toTrack.Level;
                int maxLessThan = -1;
                foreach (int k in levelValuePairs.Keys)
                {
                    if (k <= level)
                    {
                        if (maxLessThan < k)
                            maxLessThan = k;
                    }
                }

                return levelValuePairs[maxLessThan];
            }
        }
    }
}
